﻿using System.Text.RegularExpressions;
using GC_FFW.SoccerfameParser.Abstractions.Helpers.Validators;
using GC_FFW.SoccerfameParser.Common;

namespace GC_FFW.SoccerfameParser.Helpers.Validators
{
	public class UrlValidator : UrlBaseValidator
	{
		#region Variables

		private readonly Regex _rgxUrl;

		#endregion

		#region Constructors

		public UrlValidator()
		{
			_rgxUrl = new Regex(Constants.VALID_PAGE_URL_PATTERN);
		}

		#endregion

		#region UrlBaseValidator Members

		public override bool IsValidUrl(string pageUrl)
		{
			if (!UrlComparer.IsPrefix(pageUrl, Constants.PAGE_URL_PREFIX))
			{
				pageUrl = string.Concat(Constants.PAGE_URL_PREFIX, pageUrl);
			}

			return _rgxUrl.IsMatch(pageUrl);
		}

		#endregion
	}
}
